﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace SpaceFight
{
    /// <summary>
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        SpriteFont spriteFont;

        public ModelManager modelManager { get; protected set; }
        public Camera camera { get; protected set; }

        Texture2D tex1;
        SpriteFont text;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 1024;
            
        }

   
        protected override void Initialize()
        {
            camera = new Camera(this, GraphicsDevice, Vector3.Zero, 0, 0, 0, MathHelper.PiOver2, 10, 10, 2000);
            Components.Add(camera);
            modelManager = new ModelManager(this);
            Components.Add(modelManager);
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Components.Add(new Framerate(this, spriteBatch));
            base.Initialize();
        }

 
        protected override void LoadContent()
        {
            tex1 = Content.Load<Texture2D>("Textures/text_right1");
            text = Content.Load<SpriteFont>("Fonts/Text1");
            
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            camera.SetTarget(modelManager.GetPlayerWorldMatrix().Translation);

         

            base.Update(gameTime);
        }
       
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();
            spriteBatch.Draw(tex1, new Rectangle(0, 0, 1280, 1080), Color.White);
            
            //spriteBatch.DrawString(text, camera.GetCameraDirection.ToString(), new Vector2(50, 20), Color.White);
            spriteBatch.End();
          

            base.Draw(gameTime);
        }
    }
}
